package com.sxhuayuan.parking.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.sxhuayuan.parking.entity.OriginalParkingInfo;

public interface OriginalParkingInfoDao extends BaseDao<OriginalParkingInfo, Long> {

	/** 根据订单号查询 */
	@Query(value = "select info from OriginalParkingInfo info where info.lotOrderNo = ?1")
	OriginalParkingInfo findByParkingLotOrderNo(String lotOrderNo);

	/** 根据收费号查询 */
	@Query(value = "select info from OriginalParkingInfo info where info.chargeSeqNo = ?1")
	OriginalParkingInfo findByChargeSeqNo(String chargeSeqNo);

	/** 根据 进场时间查询entertime查询 */
	@Query(value = "select info from OriginalParkingInfo info where info.carNo=?1 and info.entertime =?2 and info.calcstarttime =?3")
	OriginalParkingInfo findByCarNoAndEntertime(String carNo, String entertime, String calcstarttime);

	@Modifying
	@Query(value = "delete from hypk_original_parking_info where pay_status=0 and create_date<?1", nativeQuery = true)
	void clearTimeoutOrders(String endTime);
}
